name = om-gtun
debug = true

version = 0.0.2a
description = This is a simple guitar tuner with cli and EFL-based gui.
author = Kayo <kayo.k11.4@gmail.com>
homepage = http://om-gtun.googlecode.com

package-name = $(name)
package-version = $(version)
package-description = $(description)
package-section = openmoko/applications
package-priority = optional
package-maintainer = $(author)
package-homepage = $(homepage)
package-architecture = armv4t
package-depends = libecore0 libedje0 libevas0 libfftw3-3 libdbus-1-3
package-source = none

sources = audio.c analize.c compare.c gui.c cli.c udbus.c main.c
depends = evas ecore edje ecore-evas dbus-1

prefix=$(DESTDIR)
objects = $(sources:.c=.o)
CFLAGS += $(shell pkg-config --cflags $(depends)) -DNAME=\"$(name)\"
LDFLAGS += -lfftw3 -lm -lasound $(shell pkg-config --libs $(depends))
ifdef debug
CFLAGS += -g
endif

all: $(name).elf $(name).edj

%.edj: %.edc
	edje_cc $< $@

$(name).edj:
	ln -s theme.edj $(name).edj

$(name).elf: $(objects)
	$(CC) -o $@ $^ $(LDFLAGS)

install:
	install -m 755 -d $(prefix)/usr/bin
	install -m 755 -t $(prefix)/usr/bin $(name) $(name).elf
	install -m 755 -d $(prefix)/usr/share/applications
	install -m 644 -t $(prefix)/usr/share/applications $(name).desktop
	install -m 755 -d $(prefix)/usr/share/pixmaps
	install -m 644 -t $(prefix)/usr/share/pixmaps $(name).png
	install -m 755 -d $(prefix)/usr/share/$(name)
	install -m 644 -t $(prefix)/usr/share/$(name) theme.edj
#	install -m 755 -d $(prefix)/usr/share/openmoko/scenarios
#	install -m 644 $(name).state $(prefix)/usr/share/openmoko/scenarios/$(name).state

$(name)_control:
	rm -f $@
	echo "Package: $(package-name)" >> $@
	echo "Version: $(package-version)" >> $@
	echo "Description: $(package-description)" >> $@
	echo "Section: $(package-section)" >> $@
	echo "Priority: $(package-priority)" >> $@
	echo "Maintainer: $(package-maintainer)" >> $@
	echo "Architecture: $(package-architecture)" >> $@
	echo "Homepage: $(package-homepage)" >> $@
	echo "Depends: $(package-depends)" >> $@
	echo "Source: $(package-source)" >> $@
.PHONY: $(name)_control

ipk: $(name)_control all
	rm -rf /tmp/.-ipkg-tmp
	om-make-ipkg . $<

clean:
	rm -f *.o *.bin *.elf *~ *.ipk

s2n:
	ssh root@neo 'killall om-gtun.elf; exit 0'
	scp $(name) $(name).elf $(name).edj theme.edj $(sources) root@neo:/home/root/gtun
#ssh root@neo 'cd /home/root/gtun; ./om-gtun.elf'
